/** 
 * Project Name:dyrj-admin
 * File Name:LoginController.java 
 * Package Name:com.dyrj.base.system.login.controller
 * Date:2017年10月6日上午12:28:08 
 * Copyright (c) 2017, zhang.xiangyu@foxmail.com All Rights Reserved. 
 */  
package com.dyrj.base.system.login.controller;

import javax.annotation.Resource;

import com.dyrj.base.system.user.dao.SysUserMapper;
import com.dyrj.pig.result.JsonResult;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dyrj.component.OperateLog;
import com.dyrj.base.system.login.service.LoginService;
import com.dyrj.base.system.user.model.SysUser;
import com.dyrj.vo.ResultMsg;

import java.util.Map;

/**   
 * @Title: LoginController.java 
 * @Package com.dyrj.base.system.login.controller
 * @Description: TODO(登陆) 
 * @author
 * @date 2017年10月6日 上午12:28:08 
 * @version V1.0   
 */
@Controller
public class LoginController {
	@Resource
	private LoginService loginService;
	@Resource
	private SysUserMapper sysUserMapper;
	/**
	 * @Title: index 
	 * @Description: TODO(返回登陆首页) 
	 * @param @return    设定文件 
	 * @return String    返回类型 
	 * @throws
	 */
	@GetMapping("/login")
	public String login() {
		return "login";
	}
	@GetMapping("/login4")
	public String login4() {
		return "login4";
	}
	@GetMapping("/login0")
	public String login0() {
		return "login";
	}

	@GetMapping("/login1")
	public String login1() {
		return "login1";
	}

	@GetMapping("/login2")
	public String login2() {
		return "login2";
	}

	@GetMapping("/login3")
	public String login3() {
		return "login3";
	}

	/**
	 * @Title: validate 
	 * @Description: TODO(验证用户，并返回token) 
	 * @param user
	 * @param
	 * @RequestBody 必须指定参数获取位置，否则无法获取到参数
	 * @return boolean    返回类型
	 */
	@PostMapping("/validate")
	@ResponseBody
	@OperateLog("用户登陆")
	public ResultMsg validate(SysUser user) {
		ResultMsg resultMsg = loginService.validate(user);
		return resultMsg;
	}
	
	/**
	 * @Title: index 
	 * @Description: TODO(主页) 
	 * @return
	 * @return String    返回类型
	 */
	@GetMapping("/")
	public String index() {
		return "index";
//		return UrlBasedViewResolver.FORWARD_URL_PREFIX +  "/index.html.back";
	}

	/**
	 * 找回密码
	 * @return
	 */
	@GetMapping("/forget")
	public String forget() {
		return "forget";
	}

	/**
	 * 发送短信验证码
	 * @param phone
	 * @return
	 */
	@PostMapping("/forget/sms")
	@ResponseBody
	public ResultMsg sms(String phone) {
		return new ResultMsg(200, "发送成功。");
	}

	/**
	 * 短信校验
	 * @param valicode
	 * @return
	 */
	@PostMapping("/forget/validate")
	@ResponseBody
	public ResultMsg validate(Integer valicode) {
		return new ResultMsg(200, "验证成功。");
	}
}
  